<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<style type="text/css">
    input{
        height: 30px;
    }
    #test1{
        width: 300px;
    }
    #a{
        text-decoration:none;
    }
</style>
<body>
<div>首页/服务类型管理</div><hr />
<form id="myForm">
    <table border="1px" width="600px"rules="rows" height="350px">
        <tr align="center">
            <td colspan="2"><b>请修改服务</b></td>
        </tr>
        <tr align="center">
            <td>服务Id：</td>
            <td>
                <input type="text" id="test1" name="servicetypeid" readonly="readonly">
            </td>
        </tr>
        <tr align="center">
            <td>请输入服务名称：</td>
            <td>
                <input type="text" id="test1" name="servicetypename"/>
            </td>
        </tr>
        <tr align="center">
            <td>请输入服务价格：</td>
            <td>
                <input type="text" id="test1" name="servicetypeserviceprice"/>
            </td>
        </tr>
        <tr align="center">
            <td>请输入服务简介：</td>
            <td>
               <textarea rows="5" cols="40" name="servicetypemark"></textarea>
            </td>
        </tr>
        <tr align="center">
            <td colspan="2">
                <input type="button" value="修改" id="agreementSub" />
                <a href="/admin/serviceType.html" id="a"><input type="button" value="返回"/></a>
            </td>
        </tr>
    </table>
</form>
</body>
<script type="text/javascript" src="assets/js/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
    $(function(){
        var s=location.search;
        var Id= s.substring(s.indexOf("=")+1,s.length);
        $(".datas").empty();
        $("#TableTail").empty();
       say(Id);
    })

    $("#agreementSub").click(function () {
        var servicetypeid= $("input[name=servicetypeid]").val();
        $.ajax({
            type: "POST",   //提交的方法
            url:"/updateServiceType", //提交的地址
            data:$('#myForm').serialize(),// 序列化表单值
            async: false,
            success: function(data) {  //成功
                window.location.href="/admin/serviceType.html";
            }
        });
    });
    function say(Id) {
        $.ajax({
            url:"/queryServiceTypeById",
            data:{"servicetypeid":Id},
            type:"post",
            dataType:"json",
            success:function (data) {
                if(data){
                    $("input[name=servicetypeid]").val(data.servicetypeid);
                    $("input[name=servicetypename]").val(data.servicetypename);
                    $("input[name=servicetypeserviceprice]").val(data.servicetypeserviceprice);
                    $("textarea[name=servicetypemark]").val(data.servicetypemark);
                }
            }
        });
    }
</script>
</html>
